Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Scoreboard - Bot Script Help

  1. #11
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Did you manage to display the client id with the first widget?

    Note that I made it so this widget is sent only once to each client since this value does not change for the duration of a match. See the relevant bit of code:
    if (!local.player.has_client_id_displayed) {
            local.player.has_client_id_displayed = 1;

    I strongly recommend everyone to do this when dealing with globalwidgetcommand, huddraw or ihuddraw. Only update if there is something to update. Not doing so will bloat packets sent of the network, causing them to be split up in more packets, meaning there's more traffic and more chance that a packet will be lost, meaning the server has to resend those lost packets, meaning more traffic etc...

    Anyway, I'm not at my home computer but I believe you only need to stufftext the cvar again to update the display of the widget. I'll elaborate on this further when I get home.

    Don't forget to set up the rect, alignment and other properties of your widgets. I just pulled those snippets from my old mods and from some other mod. Play with it until it suits your needs.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  2. #12

    Default

    Indeed, client Id displayed fine for the dday global widget - thanks.

    So I moved a couple lines down to start dday2 as a test.

    ...But when trying to replicate that for Local.player.bot_killcount with the dday2 globalwidget, the dday2 HUD area is "there"' but has blank text....

    Code:
    main:
    
    {
    if ($player[local.i].killcount == NIL)
    	$player[local.i].killcount = 0
    
    if ($player[local.i].bot_killcount == NIL)
    	$player[local.i].bot_killcount = 0
    
    if ($player[local.i].deathcount == NIL)
    	$player[local.i].deathcount = 0
    }
    
    while(1) {
        for(local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            if (!local.player.has_client_id_displayed) {
                local.player.has_client_id_displayed = 1;
    
    // Widget 1. DISPLAYS CLIENT ID
                local.player stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday1 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday1 fadein 1"
                local.player stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday1 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday1 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday1 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand june6 rect 64 288 512 64"
                local.player stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand june6 font handle-16"
                local.player stufftext "globalwidgetcommand june6 shader townhallwindow"
                local.player stufftext ("set client_id_msg You are Player: " + local.player.entnum);
                local.player stufftext "globalwidgetcommand june6 linkcvar client_id_msg"
                local.player stufftext "showmenu dday1"
    
    // Widget 2 DISPLAYS BOT KILLS    
                local.player stufftext "globalwidgetcommand dday2 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday2 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday2 fadein 1"
                local.player stufftext "globalwidgetcommand dday2 menu dday2 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday2 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday2 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday2 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand charliesector 252 -170 -40 100 100"
                local.player stufftext "globalwidgetcommand charliesector fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand charliesector bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand charliesector font handle-16"
                local.player stufftext "globalwidgetcommand charliesector shader townhallwindow"
                local.player stufftext ("set bot_kill_msg Bot Frags: " + local.player.bot_killcount);
                local.player stufftext "globalwidgetcommand charliesector linkcvar bot_kill_msg"
                local.player stufftext "showmenu dday2"
    
            }
        }
        wait 1
    }
    
    end

  3. #13
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    It's still inside that if statement from what I can tell. Also, local.i is not defined at the point you are zeroing out those counters.

    while(1) {
        for(local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            if (!local.player.has_client_id_displayed) {
                local.player.has_client_id_displayed = 1;
    
    // Widget 1. DISPLAYS CLIENT ID
                local.player stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday1 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday1 fadein 1"
                local.player stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday1 virtualres 0"
                local.player stufftext "globalwidgetcommand dday1 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday1 bgfill 0 0 0 0.00"
    
                local.player stufftext "globalwidgetcommand june6 rect 64 288 512 64"
                local.player stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand june6 font handle-16"
                local.player stufftext "globalwidgetcommand june6 shader townhallwindow"
                local.player stufftext ("set client_id_msg You are Player: " + local.player.entnum);
                local.player stufftext "globalwidgetcommand june6 linkcvar client_id_msg"
                local.player stufftext "showmenu dday1"
            }
    
            if (local.player.killcount == NIL)
                local.player.killcount = 0
            if (local.player.bot_killcount == NIL)
                local.player.bot_killcount = 0
            if (local.player.deathcount == NIL)
                local.player.deathcount = 0
    
            if (local.player.bot_kills_displayed != local.player.bot_killcount) {
                local.player.bot_kills_displayed = local.player.bot_killcount;
    
    // Widget 2 DISPLAYS BOT KILLS
                local.player stufftext "globalwidgetcommand dday2 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday2 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday2 fadein 1"
                local.player stufftext "globalwidgetcommand dday2 menu dday2 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday2 virtualres 0"
                local.player stufftext "globalwidgetcommand dday2 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday2 bgfill 0 0 0 0.00"
    
                local.player stufftext "globalwidgetcommand charliesector 252 -170 -40 100 100"
                local.player stufftext "globalwidgetcommand charliesector fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand charliesector bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand charliesector font handle-16"
                local.player stufftext "globalwidgetcommand charliesector shader townhallwindow"
                local.player stufftext ("set bot_kill_msg Bot Frags: " + local.player.bot_killcount);
                local.player stufftext "globalwidgetcommand charliesector linkcvar bot_kill_msg"
                local.player stufftext "showmenu dday2"
            }
        }
        wait 1
    }

    This should display the bot kills correctly and, as I've explained earlier, it should only update the display if the counter has changed.
    Last edited by Sor; October 7th, 2015 at 12:55 PM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  4. #14

    Default

    Nice one Sor! Wow. It worked! Excellent. Now I can use all 3 globalwidgets.

    One more point - I wanted to take this further, and setup 5 small achievements per map within this, and I keep breaking the script when I try.

    So, the 3rd global widget I will use for "Achievements", but I don't know why I'm breaking it.

    I have scripts elsewhere (fireworks and funcrate targets) that I will add soon, but first thing is to work out how to show achievements from the bot_killcount.

    My plan: Total of 10 achievement points to acquire per map.
    Kill 5 bots - 1 point (related to local.player.bot_killcount)
    Kill 10 bots - 2 points (related to local.player.bot_killcount)
    Kill 20 bots - 5 point (related to local.player.bot_killcount)
    Set off a Firework - 1 point (related to unknown right now, commented out, but I will investigate within it's script soon)
    Shoot the Funcrate - 1 point (related to unknown right now, commented out, but I will investigate within it's script soon)
    When each is achieved a locprint centre HUD of "Achievement Unlocked: blah blah" for each would be awesome, or maybe that's not possible as widgets are used...

    I tried the below by ceating local.player.achievement to achieve this but failed. Nothing displays after the 1st widget player name widget - I think I'm going beyond my knowledge here. Any help at all is always appreciated....

    Code:
    main:
    
    local.player.achievement = 0
    
    while(1) {
        for(local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            if (!local.player.has_client_id_displayed) {
                local.player.has_client_id_displayed = 1;
    
    // Widget 1 DISPLAYS CLIENT ID
    
                local.player stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday1 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday1 fadein 1"
                local.player stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday1 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday1 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday1 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand june6 rect 64 288 512 64"
                local.player stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand june6 font handle-16"
                local.player stufftext "globalwidgetcommand june6 shader townhallwindow"
                local.player stufftext ("set client_id_msg You are Player: " + local.player.entnum);
                local.player stufftext "globalwidgetcommand june6 linkcvar client_id_msg"
                local.player stufftext "showmenu dday1"
            }
    
            if (local.player.killcount == NIL)
                local.player.killcount = 0
    
            if (local.player.bot_killcount == NIL)
                local.player.bot_killcount = 0        
    
            if (local.player.deathcount == NIL)
                local.player.deathcount = 0
    
            if (local.player.bot_kills_displayed != local.player.bot_killcount)
                local.player.bot_kills_displayed = local.player.bot_killcount;
    
            if (local.player.kills_displayed != local.player.killcount)
                local.player.kills_displayed = local.player.killcount;
    
            if (local.player.deathcount_displayed != local.player.deathcount)
                local.player.deathcount_displayed = local.player.deathcount;
    
    	if (local.player.achievement_displayed != local.player.achievement) {
    	    local.player.achievement_displayed = local.player.achievement;
    
    
    // Widget 2 DISPLAYS BOT KILLS AND HUMAN KILLS 
       
                local.player stufftext "globalwidgetcommand dday2 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday2 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday2 fadein 1"
                local.player stufftext "globalwidgetcommand dday2 menu dday2 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday2 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday2 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday2 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand charliesector rect 65 -170 -40 100 100"
                local.player stufftext "globalwidgetcommand charliesector fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand charliesector bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand charliesector font handle-16"
                local.player stufftext "globalwidgetcommand charliesector shader townhallwindow"
                local.player stufftext ("set bot_kill_msg Bot Frags/Human Frags : " + local.player.bot_killcount + " / " + local.player.killcount);
                local.player stufftext "globalwidgetcommand charliesector linkcvar bot_kill_msg"
                local.player stufftext "showmenu dday2"
    
    
            }
    
            if (local.player.bot_killcount == 5)
                local.player.achievement = local.player.achievement + 1
                locprint "BLAH BLAH"
    
            if (local.player.bot_killcount == 10)
                local.player.achievement = local.player.achievement + 2 
                locprint "BLAH BLAH"
    
              if (local.player.bot_killcount == 20)
                local.player.achievement = local.player.achievement + 5 
                locprint "BLAH BLAH"
    
            //if (INSERT FUN CRATE == EXPLODED)
            //  local.player.achievement = local.player.achievement + 1 
                locprint "BLAH BLAH"
    
            //if (INSERT FIREWORK == EXPLODED)
            //  local.player.achievement = local.player.achievement + 1 
                 locprint "BLAH BLAH"
            {
    
    
    // Widget 3 DISPLAYS ACHIEVEMENTS   
    
    
    	    local.player stufftext "globalwidgetcommand credits2 name credits1"
    	    local.player stufftext "globalwidgetcommand credits1 shader townhallwindow"
    	    local.player stufftext "globalwidgetcommand credits1 fgcolor 1.00 0.00 1.00 1.00"
    	    local.player stufftext "globalwidgetcommand credits1 bgcolor 0.00 0.00 0.00 0.00"
    	    local.player stufftext "globalwidgetcommand credits1 fadein 1"
    	    local.player stufftext "globalwidgetcommand credits1 menu credits2 640 480 NONE 0"
    	    local.player stufftext "globalwidgetcommand credits1 virtualres 0"
    	    local.player stufftext "globalwidgetcommand credits1 fullscreen 0"
    	    local.player stufftext "globalwidgetcommand credits1 name credits2"
    
    	    local.player stufftext "globalwidgetcommand credits1 rect 66 -170 -30 100 100"
    	    local.player stufftext "globalwidgetcommand credits1 fgcolor 1.00 3.00 4.00 6.00"
    	    local.player stufftext "globalwidgetcommand credits1 bgcolor 0.00 0.00 0.00 0.00"
    	    local.player stufftext "globalwidgetcommand credits1 font handle-16"
    	    local.player stufftext "globalwidgetcommand credits1 shader townhallwindow"
    	    local.player stufftext ("set achieve_msg Achievements: " + local.player.achievement + " /5");
    	    local.player stufftext "globalwidgetcommand credits1 linkcvar achieve_msg"
    	    local.player stufftext "showmenu credits1"
    
            }
        }
        wait 1
    }
    
    end
    Last edited by OhGaz; October 8th, 2015 at 06:41 AM.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •